<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class BeForPasswordChangePasswordValidata extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
     public function rules()
     {
         return [
             'phone'                 => ['required', 'regex:/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u'],
             'password1'             => 'required|min:6',
             'password2'             => 'required|min:6',
             'password'              => 'required|confirmed|min:6',
             'password_confirmation' => 'required',
         ];
     }

     public function messages()
     {
         return [
             'phone.required'                 => '手机号码不能为空',
             'phone.regex'                    => '手机号格式不正确',
             'password1.required'             => '旧密码不能少于两个',
             'password2.required'             => '旧密码不能少于两个',
             'password1.min'                  => '密码不能少于6位',
             'password2.min'                  => '密码不能少于6位',
             'password.required'              => '请填写要修改的密码',
             'password.min'                   => '密码不能少于6位',
             'password.confirmed'             => '两次内容不相同',
             'password_confirmation.required' => '确认密码不能为空',
         ];
     }
}
